
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>端口扫描详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">IP地址</label>
                            <div class="layui-input-inline">
                                <input type="text" name="host" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">端口</label>
                            <div class="layui-input-inline">
                                <input type="text" name="port" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">服务</label>
                            <div class="layui-input-inline">
                                <input type="text" name="servicename" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">Url</label>
                            <div class="layui-input-inline">
                                <input type="text" name="url" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">Title</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="export"><i class="layui-icon">&#xe67d;</i>导出数据 </button>
            </div>
        </script>

        <table class="layui-hide" id="currentTable_portscanDetails" lay-filter="currentTableFilter"></table>

        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-md6">
                <div id="echarts-server" style="background-color:#ffffff;min-height:300px;padding: 10px"></div>
            </div>
            <div class="layui-col-xs12 layui-col-md6">
                <div id="echarts-port" style="background-color:#ffffff;min-height:300px;padding: 10px"></div>
            </div>
        </div>

    </div>

</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','echarts'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            echarts = layui.echarts;

        var TaskName = localStorage.getItem("task_name");
        if (TaskName === ""){
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        }

        table.render({
            elem: '#currentTable_portscanDetails',
            url: "/api/util/portscan/show",
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            where:{"taskname": TaskName},
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'id', width: 60, title: 'ID', sort: true},
                {field: 'host', width: 160, title: 'IP地址'},
                {field: 'port', width: 100, title: '端口'},
                {field: 'service_name', width: 130, title: '服务'},
                {field: 'url', width: 260, title: 'URL', templet:"<div><a href=\"{{d.url}}\" target=\"view_window\" class=\"layui-table-link\">{{d.url}}</a></div>"},
                {field: 'code', width: 100, title: 'Code',templet: function(d){
                    if(d.code == 0){
                        d.code = "";
                    }
                    return d.code;
                    }},
                {field: 'title', width: 300, title: 'Title'},
                {field: 'vendor_product', width: 200, title: '详细'},
                {field: 'version', width: 150, title: '版本'},
                {field: 'create_at', minWidth: 300, title: '添加时间'},
            ]],
            limits: [10, 20, 40, 60, 80, 100],
            limit: 20,
            page: true,
            skin: 'line'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);

            //执行搜索重载
            table.reload('currentTable_portscanDetails', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        //头工具栏事件
        table.on('toolbar(currentTableFilter)', function(obj){
            if(obj.event == "export"){
                window.location.href='/api/util/portscan/export/' + TaskName;
            }
        });

        var echartsPies = echarts.init(document.getElementById('echarts-server'), 'walden');
        var echartsPiesPort = echarts.init(document.getElementById('echarts-port'), 'walden');
        $.ajax({
            url: "/api/util/portscan/echarts",
            type: 'post',
            data: JSON.stringify({"taskname":TaskName}),
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            success: function (result) {
                if (result.code == 200) {
                    echartsPies.setOption({
                        title: {
                            text: '服务分布图',
                            left: 'center'
                        },
                        tooltip: {},
                        series: [
                            {
                                name: '服务统计',
                                type: 'pie',
                                roseType: 'radius',
                                data: result.data,
                                emphasis: {
                                    itemStyle: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    })
                    echartsPiesPort.setOption({
                        title: {
                            text: '端口分布图',
                            left: 'center'
                        },
                        tooltip: {},
                        series: [
                            {
                                name: '端口统计',
                                type: 'pie',
                                roseType: 'radius',
                                data: result.data1,
                                emphasis: {
                                    itemStyle: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    })
                }
            },
            error: function (e) {
                layer.alert(JSON.stringify(e), {title: '提示', icon: 2})
            }
        });
        });
</script>

</body>
</html>
